using System;
using System.Collections;
using UnityEngine;

public class ElementHighlighter : MonoBehaviour
{
	private UIPanel _myPanel;

	private UIPanel myPanel
	{
		get
		{
			if (_myPanel == null)
			{
				_myPanel = GetComponent<UIPanel>();
			}
			return _myPanel;
		}
	}

	public void HighlightItem(UIWidget item, Action callback = null, float durationInSec = 2f)
	{
		base.gameObject.SetActive(true);
		StartCoroutine(DoShowHighlight(item, callback, durationInSec));
	}

	private IEnumerator DoShowHighlight(UIWidget item, Action callback, float durationInSec)
	{
		Transform oldParent = item.transform.parent;
		int oldDepth = item.depth;
		item.transform.parent = base.transform;
		item.depth = 1;
		item.gameObject.SetActive(false);
		item.gameObject.SetActive(true);
		float currentTime = 0f;
		while (currentTime < durationInSec)
		{
			currentTime += RealTime.deltaTime;
			yield return null;
		}
		item.transform.parent = oldParent;
		item.depth = oldDepth;
		item.gameObject.SetActive(false);
		item.gameObject.SetActive(true);
		if (callback != null)
		{
			callback();
		}
		base.gameObject.SetActive(false);
	}
}
